package cn.sccl.dirms.topo.discovery.model;

import cn.sccl.common.exception.BusinessException;
import cn.sccl.common.model.BaseModel;

/**
* 自动发现任务表
* 数据库表 T_TOPO_DISCOVER_TASK 的实体对象
* Created by _minus on 2017-10-12.
*/
public class DiscoverTask extends BaseModel{
   /**
   *表名
   */
   public final static String TABLE_NAME ="t_topo_discover_task";

    private String discoverRuleDetail;//发现规则的json字串
    private String graphyId;//topo图id
    private String userId;//定制改任务的用户id
    private String name;//任务名称
    private String active;//是否启用;0 不启用，1启用
    private String groupName;//任务组
    private String targetObject;//所调用的service
    private String targetMethod;//所执行的方法

    public void setDiscoverRuleDetail(String discoverRuleDetail){
        this.discoverRuleDetail = discoverRuleDetail;
    }

    public String getDiscoverRuleDetail(){
        return this.discoverRuleDetail;
    }
    public void setGraphyId(String graphyId){
        this.graphyId = graphyId;
    }

    public String getGraphyId(){
        return this.graphyId;
    }
    public void setUserId(String userId){
        this.userId = userId;
    }

    public String getUserId(){
        return this.userId;
    }
    public void setName(String name){
        this.name = name;
    }

    public String getName(){
        return this.name;
    }
    public void setActive(String active){
        this.active = active;
    }

    public String getActive(){
        return this.active;
    }
    public void setGroupName(String groupName){
        this.groupName = groupName;
    }

    public String getGroupName(){
        return this.groupName;
    }
    public void setTargetObject(String targetObject){
        this.targetObject = targetObject;
    }

    public String getTargetObject(){
        return this.targetObject;
    }
    public void setTargetMethod(String targetMethod){
        this.targetMethod = targetMethod;
    }

    public String getTargetMethod(){
        return this.targetMethod;
    }

    /**
    * clone一个对象。
    * @param cls 需要克隆的对象类型，只能是当前类的子类
    * @param <T>
    * @return
    * @throws IllegalAccessException
    * @throws InstantiationException
    */
    public <T extends DiscoverTask> T clone(Class<T> cls) {
       try {
          T t = cls.newInstance();
          t.setId(this.getId());
          t.setDeleteFlag(this.isDeleteFlag());
          t.setCreateTime(this.getCreateTime());
          t.setUpdateTime(this.getUpdateTime());
          /*t.setPosition(this.getPosition());
          t.setUpdateUser(this.getUpdateUser());
          t.setCreateUser(this.getCreateUser());*/
          t.setDiscoverRuleDetail(this.getDiscoverRuleDetail());
          t.setGraphyId(this.getGraphyId());
          t.setUserId(this.getUserId());
          t.setName(this.getName());
          t.setActive(this.getActive());
          t.setGroupName(this.getGroupName());
          t.setTargetObject(this.getTargetObject());
          t.setTargetMethod(this.getTargetMethod());
          return t;
       } catch (Exception e) {
          e.printStackTrace();
          throw new BusinessException("对象克隆失败，请克隆的目标对象是否具有无参的构造函数。", e.getCause());
       }
    }
}